#include <unistd.h>
#include <stdio.h>



int main(int argc , char * argv[]){
 

  int result = -1;
  while((result=getopt(argc,argv,":ab:")) !=-1){
     switch(result){
           case 'a':
              printf("set a\n");
              break;

           case 'b':
              printf("set b:%s\n",optarg);
              break;

           case '?':
              printf("invalid opt\n");
              break;
           case ':':
	      printf("invalid arg\n");
              break;
           default :
              printf("default\n");
              break;
     }
    
     printf("optind:%d optarg:%s\n",optind,argv[optind]);
  }

  return 0;
}
